<!--
/**************************************************
* @ orderstatustrace.jsp
*
* Copyright   2005 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/03/15, owen
*   1) first release
*  v1.10, 2006/03/17, Jenny Li
*	1)修改订货单位和送货地址的联动查询 
*   2)修改明细状态为动态查询
*   3)更正分页查询不到结果的问题
*  
/**************************************************
-->
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>
<html>
<head>
<title>订单采购跟踪</title>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/css.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
<%
	HashMap tMap = (HashMap)request.getAttribute("orderdept");
	ArrayList tOrderDeptList = (ArrayList)tMap.get("organization");
	ResultProcess tOrder = (ResultProcess)request.getAttribute("order");
	ArrayList tList = new ArrayList();
	String [] tStr = null;
%>
<script>
	var counter;
	function process(val){
		if(val == 'Q'){
			var tStr = "";		
			var tEnd = "";				
			if(!isEmpty(ordercancelform.orderCreateDateStr.value)){
				tStr = ordercancelform.orderCreateDateStr.value.substr(0,4) + ordercancelform.orderCreateDateStr.value.substr(5,2) + ordercancelform.orderCreateDateStr.value.substr(8,2);
			}
			if(!isEmpty(ordercancelform.orderCreateDateEnd.value)){
				tEnd = ordercancelform.orderCreateDateEnd.value.substr(0,4) + ordercancelform.orderCreateDateEnd.value.substr(5,2) + ordercancelform.orderCreateDateEnd.value.substr(8,2);						
			}
			if(parseInt(tStr) > parseInt(tEnd)){
					alert("订单创建周期的开始日期不能大于截至日期！");
					return false;
			}		
			ordercancelform.action = "<%=response.encodeURL(root+"/A100602.do")%>";
    		ordercancelform.submit();			
		}else if(val == 'C'){
			ordercancelform.orderId.value ="";
			ordercancelform.orderDetailStatus.value="0000";			
			ordercancelform.orderDeptId.value="0000";
			
			var listbox = document.getElementById("deliverGoodsAddrId");
			listbox.length = 0;
			var option = new Option();
			option.text = "---全部---";
			option.value = "0000";			
			listbox.options[listbox.length] = option;
			
			ordercancelform.concentricityId.value = "";
			ordercancelform.manufInfo.value = "";
			ordercancelform.orderCreateDateStr.value = "";						
			ordercancelform.orderCreateDateEnd.value = "";									
			return;
		}else if(val == 'T'){
			//alert("--"+document.pager.indexs.length);
			//if(!isCheckBoxselected(document.pager,document.pager.orderIds)){
			//	return false;				
			//}else{		
				if(confirm("是否确定取消所选采购信息？")){	
				    var orderId;					
					  if(document.pager.orderIds != null){
					  	if(document.pager.orderIds.length > 1){
							for(i=0; i<document.pager.orderIds.length;i++){
								if(document.pager.orderIds[i].checked){
									//document.form2.orderId[i].checked = true;
									alert(document.pager.orderIds[i].value);
									orderId=document.pager.orderIds[i].value;
									//document.form2.orderId[i].value=document.pager.orderId[i].value;
								}
							}
						}else if(document.pager.orderIds.checked){
								//document.form2.orderId.checked = true;
								//document.form2.orderId.value=document.pager.orderId.value;
						}
					}else{
						return false;
					}
					//=document.pager.orderIds.value
					//alert("======="+document.ordercancelform.orderDept.value);
					//alert("---"+document.pager.orderId[0].value);
					
					document.pager.action = "<%=response.encodeURL(root+"/A100604.do")%>";			
					document.pager.submit();
					alert("所选申购单明细状态设置为‘已取消’！");
				    //window.location.reload();
					return;
				}else{
					return false;
				}
			//}
		} else if(val == 'P'){
			if(confirm("是否确定打印？")){
				print_bill();//ordermanufacturevdetail.action = "<%=response.encodeURL(root+"/A100305.do")%>";			
			}else{
				return false;
			}
		}
	}
	function change(optval){
  		var val = optval;
		if(val=='0000'){
			var listbox = document.getElementById("deliverGoodsAddrId");
			listbox.length = 0;
			var option = new Option();
			option.text = "---全部---";
			option.value = "0000";			
			listbox.options[listbox.length] = option;

		}else{
  	<%
  		if(tMap!=null){
	 	   	Collection tCollection = tMap.keySet();
	        Iterator tIterator = tCollection.iterator();
  		       while(tIterator.hasNext()){
  		           String tKey = (String)tIterator.next();
  		           tList = (ArrayList)tMap.get(tKey);
  	%>
  				if(val == '<%=tKey%>'){
	  				var counter;
	  				var listbox = document.getElementById("deliverGoodsAddrId");
	  				listbox.length = 0;  		  	  			  											
	<%					
						for(int n=0;n<tList.size();n++){
						    tStr = (String[])tList.get(n);
						    String addrId = tStr[0];
						    String addrName = tStr[1];
	%>				
							var temp1 = '<%=addrId%>';
							var temp2 = '<%=addrName%>';
							var option = new Option();
							option.value = temp1;
							option.text = temp2;
							listbox.options[listbox.length] = option;						
	<%
						}
	%>
  				}
  	<%
  		    }
  		       
  		}
  	%>
  		}	
	}			
</script>

</head>

<body BGCOLOR="#f2f2f2"	text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name=ordercancelform method="get" >
<p><br></p>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td height="20">
			<table width="100%" border="0" cellspacing="0" cellpadding="1">
				<tr height="20">
					<td height="30" width="758" class="mtxt_black">申购单取消
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td class="bg_line" height="2"></td>
	</tr>
</table>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr> 
		<td> 
			<table class=bg_table id=tableId	cellspacing=1 cellpadding=0 style="padding-left:5;padding-right:5" width=100% align=center border=0>
				<TR height=20>
					<TD class="bg_column" align=center width="15%">申购单编号</TD>
					<TD align=left class="bg_row_odd" width="35%">
					<input type="text" name="orderId" value="<%=request.getParameter("orderId")==null? "":request.getParameter("orderId") %>" maxlength="20"></TD>					
					<TD class="bg_column" align=center width="15%">申购单明细状态</TD>
					<TD align=left class="bg_row_odd" width="35%">
						<select name="orderStatus">					
						<option value="00">---全部---</option>
						<%
							String tOrderDetailStatus = request.getParameter("orderStatus");
							String[][] tDetailStatus = GSBaseManager.getAllOrderDetailStatusForCancle();
							if(tDetailStatus != null && tDetailStatus.length > 0 ){
								for(int i=0; i<tDetailStatus.length; i++){
									String[] temp = tDetailStatus[i];
									if(tOrderDetailStatus != null && tOrderDetailStatus.equals(temp[0])){
						%>
										<option value="<%=temp[0]%>" selected>
										<%=temp[1]%></option>
						<%				    
									}else{
						%>
										<option value="<%=temp[0]%>" >
										<%=temp[1]%></option>
						<%			
									}
								}
							}
						%>
						</select>
					</TD>	
				</TR>
				<TR height=20>							
					<TD class="bg_column" align=center>订货单位</TD>
					<TD left=right class="bg_row_odd">
						<select name="orderDept" onChange="change(this.value)">					
						<option value="0000">---全部---</option>
						<%
							String tOrderDept = request.getParameter("orderDept");
							if(tOrderDeptList != null && tOrderDeptList.size() > 0 ){	
							    if(tOrderDept != null && tOrderDept.equals("0000")){
									for(int i=0; i<tOrderDeptList.size(); i++){
									    String[] temp = (String[])tOrderDeptList.get(i);
						%>
										<option value="<%=temp[0]%>"><%=temp[1]%></option>						
						<%			    
									}
							    }else{
									for(int i=0; i<tOrderDeptList.size(); i++){
									    String[] temp = (String[])tOrderDeptList.get(i);
										if(tOrderDept != null && tOrderDept.equals(temp[0])){
							%>
											<option value="<%=temp[0]%>" selected>
											<%=temp[1]%></option>
							<%				    
										}else{
							%>
											<option value="<%=temp[0]%>"><%=temp[1]%></option>
							<%			
										}
									}
							    }
							}

						%>

						</select>
					</TD>
					<TD class="bg_column" align=center>送货地址</TD>
					<TD align=left class="bg_row_odd" >
						<select name="deliverGoodsAddrId" id="deliverGoodsAddrId">	
						<option value="0000">---全部---</option>
						<%
							String tDeliverGoodsAddrId = request.getParameter("deliverGoodsAddrId");
							if(tOrderDept!=null && !tOrderDept.equals("0000")){
							    ArrayList tDeliverGoodsAddr = (ArrayList)tMap.get(tOrderDept);
								for(int i=0; i<tDeliverGoodsAddr.size(); i++){
								    String[] temp = (String[])tDeliverGoodsAddr.get(i);
									if(tDeliverGoodsAddrId != null && tDeliverGoodsAddrId.equals(temp[0])){
						%>
										<option value="<%=temp[0]%>" selected><%=temp[1]%></option>
						<%				    
									}else{
						%>
										<option value="<%=temp[0]%>"><%=temp[1]%></option>
						<%			
									}
								}
							}
						%>
						</select>					
					</TD>						
				</TR>				
				<TR height=20>
					<TD class="bg_column" align=center>集中编码</TD>
					<TD align=left class="bg_row_odd" colspan="3">
					<input type="text" name="concentricityId" maxlength="20" value="<%=request.getParameter("concentricityId")==null?"":request.getParameter("concentricityId")%>">
					</TD>
				</TR>									
				<TR height=20>
					<TD class="bg_column" align=center>产品信息</TD>
					<TD align=left class="bg_row_odd" colspan="3">
					<input type="text" name="manufInfo" maxlength="200" value="<%=request.getParameter("manufInfo")==null?"":request.getParameter("manufInfo")%>">（<FONT color="#ff0033">对产品名称、型号、规格、品牌、生产厂商等关键字的模糊查询</FONT>）&nbsp;
					</TD>
				</TR>									
				<TR height=20>	
					<TD class="bg_column" align=center>创建时间</TD>
					<TD align=left class="bg_row_odd" colspan="3">
					<input type="text"	name="orderCreateDateStr" value="<%=request.getParameter("orderCreateDateStr")==null?"":request.getParameter("orderCreateDateStr")%>" length="20" onfocus="setday(this)" readonly> 
					～<input type="text"	name="orderCreateDateEnd" length="20" value="<%=request.getParameter("orderCreateDateEnd")==null?"":request.getParameter("orderCreateDateEnd")%>" onfocus="setday(this)" readonly>
					</TD>
				</TR>
              <tr>
                      <%
                      if(tOrder != null) {
                          int totalRecords = 0;
                          if(request.getAttribute("totalRecords")!=null){
                              totalRecords=Integer.parseInt((String)request.getAttribute("totalRecords"));
                          }
                          int defaultPageSize =10;
                          if(request.getAttribute("pageSize")!=null){
                              defaultPageSize=Integer.parseInt((String)request.getAttribute("pageSize"));
                          }
                          totalRecords=tOrder.getRecordsSize();
                      %>          
                      <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'>
                      <%tList = tOrder.getDisplayRecords(index.intValue(),pageSize.intValue()); %>
                      </page:pager>
                      <%} %>
              </tr>
			</table>
		</td>
	</tr>
</table>
</form>
    <p align="center">  
		<input type="image" src="<%=response.encodeURL(root+"/images/button/chaxun.gif")%>" width="58" height="24" class="box" onclick="process('Q')"/>&nbsp;
		<input type="image" src="<%=response.encodeURL(root+"/images/button/clean.gif")%>" width="58" height="24" class="box" onclick="process('C')"/>&nbsp;		
    </p>
<%
	
	if(tOrder != null){
%>
	<center>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td>
            <form name ='pager'>
            <input type="hidden" name="orderId" >
            <input type="hidden" name="orderCategory">            
            <input type="hidden" name="orderDept" >            
            	<table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=100% align=center border=0>
                    <tbody> 

                    <tr class="bg_column" height=20> 
                    	<td></td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">申购单编号</div>
						</td>                    
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">申购单明细编号</div>
						</td>                    			
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">申购单明细状态</div>
						</td>												
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">集中编码</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">产品名称</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">规格</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">型号</div>
						</td>																																				
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">品牌</div>
						</td>											
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">订货数量</div>
						</td>																									
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">创建时间</div>
						</td>										
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">订货单位</div>
						</td>																																				
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">详细信息</div>
						</td>																																				
					</tr>
					<%
						if(tList != null && tList.size() > 0){
						for(int i=0; i<tList.size(); i++){
							tStr = (String[])tList.get(i);
							String tTempStr="";
							if(i%2==0){
								tTempStr="class=\"bg_row_odd\"";
							}else {
								tTempStr="class=\"bg_row_even\"";
							}
					%>
							<tr <%=tTempStr%> height=20>
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									 <input type=checkbox name=orderIds value="<%=tStr[1]%>" >								    
									 </div>
								</td>							
								<td class=top align=middle> 								
									<div align="center" class="txt_content">
									<%=tStr[0]%>
									</div>
								</td>	
								<td class=top align=middle> 								
									<div align="center" class="txt_content">
									<%=tStr[1]%>
									</div>
								</td>									
								<td class=top align=middle> 								
									<div align="center" class="txt_content">
									<%=tStr[2]%>
									</div>
								</td>	
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[3]%>
									</div>
								</td>														
								<td class=top align=middle > 								
									<div align="center" class="txt_content">
									<a href="<%=response.encodeURL(root+"/A100306.do")%>?concentricityId=<%=tStr[3]%>" target="contentForm"><%=tStr[4]%></a>
									</div>
								</td>	
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[5]%>
									</div>
								</td>				
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[6]%>
									</div>
								</td>													
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[7]%>
									</div>
								</td>
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[8]%><%=tStr[9]%>
									</div>
								</td>								
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[10]%>
									</div>
								</td>								
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=tStr[11]%>
									</div>
								</td>																												
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<a href="<%=response.encodeURL(root+"/A101003.do")%>?orderId=<%=tStr[0]%>&orderDetailId=<%=tStr[1]%>" target="contentForm">详细</a>
									</div>
								</td>																																								
							</tr> 
					<%
						}
					%>
						  <tr class="bg_column" height=20>
						    <td width="960" height="16" colspan="14" align="right">
									<!--导航条-->
						    		<page:navigator type='text' queryForm='ordercancelform'/>
						    </td>
						  </tr>					
				    <%
						}else{
					%>
							<font color="red">没有符合条件的产品订单信息</font>
					<%
						}
					%>
					</tbody>
				</table>
				</form>					  
			</td>
		</tr>
	</table>
	</center>
		<p align="center">  
	<%
		if(tList!= null && tList.size() > 0){
	%>
    <input type="image" src="<%=response.encodeURL(root+"/images/button/tijiao.gif")%>" onclick="process('T')">&nbsp;
	<!--<input type="image" src="images/button/dayin.gif" width="86" height="24" class="box" onclick="process('P')"/>&nbsp;-->
	<%
		}
	%>
    </p>	
<%		
	}
%>
</html>